<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"/>
<title>Madhouse|monitor core</title>
<link rel="stylesheet" href="../assets/css/bootstrap-spacelab.css" />
<link rel="stylesheet" href="../assets/css/base.css?t=20130516173114" />
<link rel="stylesheet" href="../assets/css/validationEngine.jquery.css" type="text/css"/>
  <!-- template
    ================================================== -->
    <script id="t_a" type="text/html">
				<form class="form-horizontal" id="form" onsubmit="return false;">
					 <fieldset>
						 <!--<legend>命令批量执行</legend>-->
						 <!--<br />-->
                        <div class="control-group">
                            <label class="control-label">服务器组：</label>
                            <div class="controls">
                                <!--<input type="text" class="validate[required,custom[url]] text-input"  name="watchdogUrl" value="" style="width:540px;" >-->
                                <select>
                                    <option value="1">hosts</option>
                                    <option value="1">hosts1</option>
                                </select>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">服务器：</label>
                            <div class="controls">
                                <input type="text" class="text-input" value="" style="width:210px;" >
                                <p class="help-block">如不填写代表服务器组内全部服务器</p>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">用户：</label>
                            <div class="controls">
                                <input type="text" class="text-input" value="" style="width:210px;" >
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">使用sudo：</label>
                            <div class="controls">
                                <input type="checkbox" class="text-input" value="">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">Forks：</label>
                            <div class="controls">
                                <input type="text" class="text-input" value="0" style="width:210px;" >
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">脚本命令：</label>
                            <div class="controls">
                                <textarea id="textarea" value="#!/bin/bash" style="width:540px;height:80px;vertical-align:top;padding:6px" rows="4" cols="25" >#!/usr/bin/env bash</textarea>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">命令参数：</label>
                            <div class="controls">
                                <input type="text" class="text-input" value="" style="width:210px;" >
                            </div>
                        </div>
					 </fieldset>
					 
					 
				
                <div class="form-actions">
                    <button class='btn btn-info' name="submit">
                        	提交 
                    </button>
                </div>			
			</form>
			
    </script>

	
<style>

</style>

</head>
<body>
    <header>
        <h1><span id="title">命令批量执行</span></h1>
        <div class="row" id="toolbar">
                <div class="box_1">
                    <button class="btn" id="info" data-toggle="modal" data-target="#modal"  data-keyboard="true" data-backdrop="true">
                        <i class="icon-info-sign"></i> 信息
                    </button>					
                </div>
				
                <div class="btn-group" style="display:none;">
                    <button class="btn">
                        	操作
                    </button>
                    <button class="btn dropdown-toggle" data-toggle="dropdown">
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="#" id="notification"></a></li>
                    </ul>
                </div>
        </div>
    </header>	
	
    <div id="mainbody">
        <div class="tab-pane active" id="set_form">
        </div>
    </div>
	

  <!-- 弹出对话框
    ================================================== -->
<div class="modal fade" id="modal">
  <div class="modal-header">
    <a class="close" data-dismiss="modal">×</a>
    <h3>help</h3>
  </div>
  <div class="modal-body">
  		此页面用于修改监控系统的常规设置.
  </div>
  <div class="modal-footer">
    <a href="#" class="btn"  data-dismiss="modal">关闭</a>
  </div>
</div>


  <!-- js part
    ================================================== -->
<script src="../assets/js/library/jquery-1.7.1.js"></script>
<script src="../assets/js/library/bootstrap.min.js"></script>
<script src="../assets/js/library/template.js"></script>
<script src="../assets/js/library/jquery.validationEngine-en.js"></script>
<script src="../assets/js/library/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
<script src="../assets/js/helper.js?t=20130516173114"></script>
<script src="../assets/js/doc.js?t=20130516173114"></script>	
<script>
$(function(){
	
	var smartMad = window.smartMad = window.smartMad || {};
	
	////////////////////////////////////////////////////
	//常规选项设置
	////////////////////////////////////////////////////
	var formConf = {
		url: smartMad._url + smartMad.api.getGenericSet
	};	
	var formCall = function(e,json){
		var $th = $(this), data, html;
		
		//$th.html(JSON.stringify(json));return;
        ///////////////////////////////////////////////
		
        data = {
            json: json
        };
        
        ///////////////////////////////////////////////
        
        html = template('t_a', data);
        $th.html(html);
		
		$('#form').validationEngine();
		
	};	
	
	
	////////////////////////////////////////////////////////
	//提交保存
	////////////////////////////////////////////////////////
    $('#mainbody')
	.delegate('button[name="submit"]', 'click', function(){
		//表单验证
		if(!$('#form').validationEngine('validate')){
			return;
		}
		
        var conf = {
			url: smartMad._url + smartMad.api.updateGenericSet
        };
		
        var watchdogUrl = $('input[name="watchdogUrl"]').val(),
		    sleepSecRep = $('input[name="sleepSecPerReq"]').val() * 1,
        	sendMail = $('input[name="sendMail"]').attr('checked') ? 1 : 0,
			sendHour = $('select[name="sendHour"]').val(),
			sendMin = $('select[name="sendMin"]').val(),
			sendSec = '00';
		
       conf.data = {
                'watchdogUrl': watchdogUrl,
                'sleepSecPerReq': sleepSecRep,
                'sendMail': sendMail,
                'sendHour': sendHour,
                'sendMin': sendMin,
                'sendSec': sendSec
            };	
		
        $(this).postData(conf);
    })
	.delegate('button[name="reset"]', 'click', function(){
		//$('#set_form').getData(formConf);
	});
    
	////////////////////////////////////////////////////////
	//init
	////////////////////////////////////////////////////////
	
	$('#set_form').bind('ajax.success', formCall).getData(formConf);
});
</script>

</body>
</html>
